package chai.ningning.chars;

import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;

/**
 * 1、java.io.Writer类的实例用来输出字符的输出流
 * 2、append（char）/append（CharSequence)/append（Char Sequence，int ,int)都是以字符为单位输出数据
 */
public class WriterTest2 {

    public static void main(String[] args) throws IOException {

        Writer  w = new FileWriter("writer2.txt");

        //将单个字符追加到当前流末尾
        w.append('a');
        w.append('b');
        w.append('c');
        w.append('\n');

        //String类实现了CharSequence接口
        String s = "竟无语凝噎";
        w.append(s);
        w.append('\n');

        StringBuffer buffer = new StringBuffer("城春草木深");
        w.append(buffer);
        w.append('\n');

        StringBuilder builder = new StringBuilder("一片冰心在玉壶");
        w.append(builder);
        w.append('\n');

        w.append(builder,2,4);

        w.close();

    }

}
